#!/bin/zsh

for filename (*Zsh-开发指南（第*md) {
    local title=${${${filename#*（}%）*}//-/ }
    echo "## [$title]("$filename")"

    for i (${(f)"$(grep "^###" $filename)"}) {
        local level=${i%% *}
        local subtitle=${i#$level }
        level=${level/"####"/- }
        echo "$level [$subtitle]("$filename"#${${${(L)subtitle// /-}//、}//：})"
    }

    echo "\n---\n"
}
